#include "mybtn.h"

#include<QPixmap>
#include<QDebug>

#include<QPropertyAnimation>

//MyBtn::MyBtn(QWidget *parent) : QPushButton(parent)
//{

//}
MyBtn::MyBtn(QString add){
    QPixmap pix;
    bool ret=pix.load(add);
    
    if(!ret){
        qDebug()<<"图片加载失败";
    }

    pix=pix.scaled(300,80);
    this->setFixedSize(pix.width(),pix.height());
    this->setStyleSheet("QPushButton{border:0px;}");
    this->setIcon(pix);
    this->setIconSize(QSize(pix.width(),pix.height()));
}

void MyBtn::zoom1(){
    QPropertyAnimation *anm1=new QPropertyAnimation(this,"geometry");
    //设置时间间隔 毫秒
    anm1->setDuration(200);
    //创建起始位置
    anm1->setStartValue(QRect(this->x(),this->y(),this->width(),this->height()));
    anm1->setEndValue(QRect(this->x(),this->y()+10,this->width(),this->height()));

    anm1->setEasingCurve(QEasingCurve::OutBounce);
    anm1->start();

}

void MyBtn::zoom2(){
    QPropertyAnimation *anm2=new QPropertyAnimation(this,"geometry");
    //设置时间间隔 毫秒
    anm2->setDuration(200);
    //创建起始位置
    anm2->setStartValue(QRect(this->x(),this->y()+10,this->width(),this->height()));
    anm2->setEndValue(QRect(this->x(),this->y(),this->width(),this->height()));

    anm2->setEasingCurve(QEasingCurve::OutBounce);
    anm2->start();
}

